﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JBeamLibrary.VehicleParts.Elements
{
    public class AxleBeams : Collection<string>
    {
        #region CTORs

        public AxleBeams()
        {
        }

        public AxleBeams(IEnumerable<string> beamNames)
        {
            AddRange(beamNames);
        }

        #endregion


        #region Methods

        public void AddRange(IEnumerable<string> beamNames)
        {
            foreach (var beamName in beamNames)
                Add(beamName);
        }

        public static AxleBeams Parse(string beamNames)
        {
            var axleBeams = new AxleBeams();
            if (string.IsNullOrEmpty(beamNames)) return axleBeams;

            axleBeams.AddRange(beamNames.Replace(" ", "").Split(','));
            return axleBeams;
        }

        public static bool TryParse(string beamNames, out AxleBeams output)
        {
            output = Parse(beamNames);
            return output.Count > 0;
        }

        #endregion

    }
}
